<?php

namespace App\Http\Requests\School;

use Illuminate\Foundation\Http\FormRequest;

/**
 * Class StoreSchoolRule
 * @package App\Http\Requests\School
 *
 * 验证学校规则表单
 */
class StoreSchoolRule extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'morning_rule' => 'required',
            'lunch_rule' => 'required',
            'dinner_rule' => 'required',
            'morning_date' => ['required', 'array', 'size:2'],
            'lunch_date' => ['required', 'array', 'size:2'],
            'dinner_date' => ['required', 'array', 'size:2'],
            'morning_deadline' => 'required',
            'lunch_deadline' => 'required',
            'dinner_deadline' => 'required'
        ];
    }

    /**
     * @return array
     */
    public function attributes()
    {
        return [
            'morning_rule' => '默认早餐规则',
            'lunch_rule' => '默认午餐规则',
            'dinner_rule' => '默认晚餐规则',
            'morning_date' => '早餐时间',
            'lunch_date' => '午餐时间',
            'dinner_date' => '晚餐时间',
            'morning_deadline' => '次日早餐截止时间',
            'lunch_deadline' => '次日午餐截止时间',
            'dinner_deadline' => '次日晚餐截止时间'
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'morning_rule.required' => '请选择:attribute',
            'lunch_rule.required' => '请选择:attribute',
            'dinner_rule.required' => '请选择:attribute',
            'morning_date.required' => '请选择:attribute',
            'morning_date.size' => ':attribute参数错误',
            'morning_date.array' => ':attribute数据类型错误',
            'lunch_date.array' => ':attribute数据类型错误',
            'lunch_date.required' => '请选择:attribute',
            'lunch_date.size' => ':attribute参数错误',
            'dinner_date.array' => ':attribute数据类型错误',
            'dinner_date.required' => '请选择:attribute',
            'dinner_date.size' => ':attribute参数错误',
            'morning_deadline.required' => '请选择:attribute',
            'lunch_deadline.required' => '请选择:attribute',
            'dinner_deadline.required' => '请选择:attribute'
        ];
    }
}
